﻿Public Class AdvetiseOverview
    Inherits System.Web.UI.Page

    Public dbmanager As DBManager = New DBManager
    'To set masterpage 
    Protected Sub Page_PreInit(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.PreInit
        'Check if user is null
        If (Session("user") IsNot Nothing) Then
            'Retrieve userAcc details from session
            Dim userLoggedIn As userAcc = Session("user")
            'Check if user is admin, assign masterpage respectively
            If userLoggedIn.isAdmin Then
                Me.MasterPageFile = "~/MasterPage/Admin.Master"
            Else
                Me.MasterPageFile = "~/MasterPage/User.Master"
            End If


        Else
            'For anonymous users
            Me.MasterPageFile = "~/MasterPage/User.Master"
            'Enable this line to prevent anonymous users from entering this page
            ' Response.Redirect("~/Login.aspx")
        End If
    End Sub
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If (Session("user") IsNot Nothing) Then
            Dim userLoggedIn As userAcc = Session("user")
            Dim advData = dbmanager.getActivePendingAdvertisements(userLoggedIn.userID)
            lblSEOPending.Text = advData(0).ToString()
            lblSEOActive.Text = advData(1).ToString()
            lblBannerPending.Text = advData(2).ToString()
            lblBannerActive.Text = advData(3).ToString()
        End If

    End Sub

    Protected Sub btnSEO_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnSEO.Click
        Response.Redirect("AdvertiseNew.aspx")
    End Sub

    Protected Sub btnBanner_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnBanner.Click
        Response.Redirect("AdvertiseNew.aspx?type=banner")
    End Sub
End Class